package gui;

import java.awt.Dimension;
import java.awt.Point;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.border.BevelBorder;

import constants.Constants;

public class AddRoomPopup {
	private JMenuItem addRoom;
	private JPopupMenu roomPopup;

	public AddRoomPopup() {
	}

	private JMenuItem getAddRoom() {
		if (addRoom == null) {
			addRoom = new JMenuItem();
			addRoom.setText("Add new Room");
			addRoom.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					HouseEditor.getInstance().AddRoomDialogMain.pack();
					Point loc = HouseEditor.getInstance().getLocation();
					loc.translate(20, 20);
					HouseEditor.getInstance().AddRoomDialogMain
							.setLocation(loc);
					HouseEditor.getInstance().AddRoomDialogMain
							.setSize(new Dimension(250, 300));
					HouseEditor.getInstance().AddRoomDialogMain
							.setVisible(true);
					HouseEditor.getInstance().Add.setEnabled(false);
					HouseEditor.getInstance().writeError("Input room data.",
							Constants.green);
				}
			});
		}
		return addRoom;
	}

	public JPopupMenu getRoomPopup() {
		if (roomPopup == null) {
			roomPopup = new JPopupMenu();
			roomPopup.setSize(new Dimension(80, 120));
			roomPopup.add(getAddRoom());
			roomPopup.setBorder(new BevelBorder(BevelBorder.RAISED));

		}
		return roomPopup;
	}

}
